package com.example.wanbaqian.adapter;

import android.content.Context;
import android.view.View;

import com.example.wanbaqian.R;
import com.example.wanbaqian.bean.RepaymentListBean;
import com.example.wanbaqian.utils.TimeUtils;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by Administrator on 2017/4/13 0013.
 * 所有借款的还款列表适配器
 */

public class RepaymentListAdapter extends CommonAdapter<RepaymentListBean> {
    public RepaymentListAdapter(Context context, int layoutId, List<RepaymentListBean> datas) {
        super(context, layoutId, datas);
    }

    @Override
    public void onViewHolderCreated(ViewHolder holder, View itemView) {
        super.onViewHolderCreated(holder, itemView);
        AutoUtils.autoSize(itemView);
    }

    @Override
    protected void convert(ViewHolder holder, RepaymentListBean repaymentListBean, int position) {
        holder.setText(R.id.item_repayment_title, repaymentListBean.getLoan_no());
        holder.setText(R.id.item_repayment_time, "借款时间:" + TimeUtils.getStrTime(repaymentListBean.getLoan_time(),""));
        holder.setText(R.id.item_repayment_money, repaymentListBean.getLoan_money());
        String Pay_status = repaymentListBean.getPay_status();
        String Repay_status = repaymentListBean.getRepay_status();
        //当显示借款成功（Pay_status==1）时就显示还款状态
        if (Pay_status.equals("1")) {
            holder.setText(R.id.item_repayment_stat, Repay_status.equals("0") ? "待还款" : Repay_status.equals("1") ? "还款中" : Repay_status.equals("2") ? "按时还款" : "提前还款");
        } else {
            holder.setText(R.id.item_repayment_stat, Pay_status.equals("0") ? "待打款" : "借款失败");
        }
    }
}
